package model;

import java.awt.Desktop;
import java.io.File;
import java.util.ArrayList;

/***.
 * Class Movie
 * @author jaubertbenjamin
 *
 */
public class Movie {

    /**.
     * movie title
     */
    private String title;
    /**.
     * year
     */
    private int year;
    /**.
     * search
     */
    private String search;
    /**.
     * plot
     */
    private String plot;
    /**.
     * path
    */
    private String path;
    /**.
     * poster
     */
    private String poster;
    /**.
     * release
     */
    private ReleaseDate release;
    /**.
     * rating
     */
    private Rating rating;
    /**.
     * runtime
     */
    private String runtime;
    /**.
     * genres
     */
    private ArrayList<String> genres;
    /**.
     * actors
     */
    private ArrayList<String> actors;
    /**.
     * directors
     */
    private ArrayList<String> directors;
    /**.
     * writers
    */
    private ArrayList<String> writers;
    /**.
     * classified
     */
    private String classified;
    /**.
     * website
     */
    private String website;
    /**.
     * production
     */
    private String production;
    /**.
     * box Office
     */
    private String boxOffice;
    /**.
     * completed
    */
    private boolean completed;

    /**.
     * Default Constructor
    */
    public Movie() {
        genres = new ArrayList<String>();
        actors = new ArrayList<String>();
        directors = new ArrayList<String>();
        writers = new ArrayList<String>();
    }

    /**.
     * Second constructor
     * @param tempPath where is located the movie
     * @param tempSearch terms used for the API
     */
    public Movie(final String tempPath, final String tempSearch) {
        this.path = tempPath;
        this.search = tempSearch;
        release = new ReleaseDate();
        rating = new Rating();
        genres = new ArrayList<String>();
        actors = new ArrayList<String>();
        directors = new ArrayList<String>();
        writers = new ArrayList<String>();
        completed = false;
    }

    /**.
     * Play the movie with the default video player of the system
     */
    public final void play() {
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
             try {
                 desktop.open(new File(this.path));
             } catch (Exception e) {
                 e.printStackTrace();
             }
        }
    }

    /**.
     * Get all the genres in a single string
     * @return the genre
     */
    public final String genres() {
        String str = null;
        str = genres.get(0);
        for (int i = 1; i < genres.size(); i++) {
            str += ", " + genres.get(i);
        }
        return str;
    }

    /**.
     * Get all the actors in a single string
     * @return actors
     */
    public final String actors() {
        String str = null;
        str = actors.get(0);
        for (int i = 1; i < actors.size(); i++) {
            str += ", " + actors.get(i);
        }
        return str;
    }

    /**.
     * Get all the directors in a single string
     * @return directors
     */
    public final String directors() {
        String str = null;
        str = directors.get(0);
        for (int i = 1; i < directors.size(); i++) {
            str += ", " + directors.get(i);
        }
        return str;
    }

    /**.
     * Get all the writers in a single string
     * @return writers
     */
    public final String writers() {
        String str = null;
        str = writers.get(0);
        for (int i = 1; i < writers.size(); i++) {
             str += ", " + writers.get(i);
        }
        return str;
    }

    /**.
     * return title
     * @return title
     */
    public final String getTitle() {
        return title;
    }

    /**.
     * set title
     * @param newTitle title of the movie
     */
    public final void setTitle(final String newTitle) {
        this.title = newTitle;
    }

    /**.
     * get the search terms
     * @return search
     */
    public final String getSearch() {
         return search;
    }

    /**.
     * set the search terms
     * @param newSearch search terms
     */
    public final void setSearch(final String newSearch) {
        this.search = newSearch;
    }

    /**.
     * get the plot
     * @return plot of the movie
     */
    public final String getPlot() {
        return plot;
    }

    /**.
     * Set the plot
     * @param synopsis the plot of the movie
     */
    public final void setPlot(final String synopsis) {
        this.plot = synopsis;
    }

    /**.
     * Get the path
     * @return path
     */
    public final String getPath() {
        return path;
    }

    /**.
     * Set the path
     * @param newPath the location of the movie
     */
    public final void setPath(final String newPath) {
         this.path = newPath;
    }

    /**.
     * get the poster
     * @return poster
     */
    public final String getPoster() {
        return poster;
    }

    /**.
     * set the poster
     * @param imagePath the path of the poster on the web
     */
    public final void setPoster(final String imagePath) {
        this.poster = imagePath;
    }

    /**.
     * Get the release date
     * @return the release date object
     */
    public final ReleaseDate getRelease() {
         return release;
    }

    /**.
     * set the release date
     * @param releaseDate release date
     */
    public final void setRelease(final ReleaseDate releaseDate) {
        this.release = releaseDate;
    }

    /**.
     * Set the rating
     * @param newRating rating of the movie
     */
    public final void setRating(final Rating newRating) {
        this.rating = newRating;
    }

    /**.
     * get the rating
     * @return rating
     */
    public final Rating getRating() {
        return rating;
    }

    /**.
     * get the runtime
     * @return runtime
     */
    public final String getRuntime() {
        return runtime;
    }

    /**.
     * Set the runtime
     * @param newRuntime the runtime
     */
    public final void setRuntime(final String newRuntime) {
       this.runtime = newRuntime;
    }

    /**.
     * get the ArrayList of actors
     * @return ArrayList<String>
     */
    public final ArrayList<String> getActors() {
        return actors;
    }

    /**.
     * Add new actor
     * @param actor new actor
     */
    public final void addActors(final String actor) {
       this.actors.add(actor);
    }

    /**.
     * get the ArrayList of genres
     * @return ArrayList<String>
     */
    public final ArrayList<String> getGenre() {
        return genres;
    }

    /**.
     * add new genre
     * @param genre new genre
     */
    public final void addGenre(final String genre) {
       this.genres.add(genre);
    }

    /**.
     * get the ArrayList of directors
     * @return ArrayList<String>
     */
    public final ArrayList<String> getDirector() {
        return directors;
    }

    /**.
     * add new director
     * @param director new director
     */
    public final void addDirector(final String director) {
        this.directors.add(director);
    }

    /**.
     * get the ArrayList of writers
     * @return ArrayList<String>
     */
    public final ArrayList<String> getWriter() {
       return writers;
    }

    /**.
     * add new writer
     * @param writer new writer
     */
    public final void addWriter(final String writer) {
        this.writers.add(writer);
    }

    /**.
     * get the classification
     * @return classified rating
     */
    public final String getClassification() {
       return classified;
    }

    /**.
     * set the classification
     * @param classification classification rating
     */
    public final void setClassification(final String classification) {
       this.classified = classification;
    }

    /**.
     * get the website
     * @return website url
     */
    public final String getWebsite() {
      return website;
    }

    /**.
     * set the website url
     * @param websiteURL website url in string
     */
    public final void setWebsite(final String websiteURL) {
      this.website = websiteURL;
    }

    /**.
     * get the production
     * @return production
     */
    public final String getProduction() {
      return production;
    }

    /**.
     * set the production
     * @param newProduction production
     */
    public final void setProduction(final String newProduction) {
       this.production = newProduction;
    }

    /**.
     * get the box Office
     * @return boxOffice
     */
    public final String getBoxOffice() {
      return boxOffice;
    }

    /**.
     * set the box office
     * @param newBoxOffice the box office
     */
    public final void setBoxOffice(final String newBoxOffice) {
       this.boxOffice = newBoxOffice;
    }

    /**.
     * return the boolean that said if the movie information is completed
     * @return true if the movie is completed, false else.
     */
    public final boolean isCompleted() {
       return completed;
    }

    /**.
     * Set the boolean
     * @param isCompleted boolean
     */
    public final void setCompleted(final boolean isCompleted) {
       this.completed = isCompleted;
    }

    /**.
     * get the year
     * @return year
     */
    public final int getYear() {
       return year;
    }

    /**.
     * set the year
     * @param newYear year
     */
    public final void setYear(final int newYear) {
      this.year = newYear;
    }

}
